package com.gui;

import com.gooddies.wiring.annotations.WiringComponent;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Dmitry
 */
@WiringComponent(singleton = true)
public class Breakpoints {
    private final Map<Integer, String> breakpoints = new HashMap<>();

    public boolean hasBreakpoint(int lineNumber) {
        return breakpoints.containsKey(lineNumber);
    }

    public String getTag(int lineNumber) {
        return breakpoints.get(lineNumber);
    }

    public String addBreakpoint(int lineNumber) {
        String tag = generateRandomString();
        breakpoints.put(lineNumber, tag);
        return tag;
    }

    public void removeBreakpoint(int lineNumber) {
        breakpoints.remove(lineNumber);
    }

    private String generateRandomString() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 10; i++) {
            sb.append('a' + ((int) (Math.random() * 60)));
        }
        return sb.toString();
    }
}
